/**
 * 
 */
const express = require('express');
const db = require('./db');
const app = express();

app.get('/books', (req, resp)=>{
    let sql = 'SELECT * FROM t_book';
    db.base(sql, null, (err, results, field)=>{
        resp.json(results);
    });
});

app.get('/book/:id', (req, resp)=>{
    let id = req.params.id
    let sql = 'SELECT * FROM t_book WHERE id = ?';
    db.base(sql, id, (err, results, field)=>{
        resp.json(results);
    });
});


app.listen(3000, ()=>{
    console.log('running...');
});
